﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.BaseInformation;
using TyMES.Model;

namespace TyMES.ViewModel.BaseInformation.LMESProductDataTemplateVMs
{
    public partial class LMESProductDataTemplateListVM : BasePagedListVM<LMESProductDataTemplate_View, LMESProductDataTemplateSearcher>
    {
        
        protected override IEnumerable<IGridColumn<LMESProductDataTemplate_View>> InitGridHeader()
        {
            return new List<GridColumn<LMESProductDataTemplate_View>>{
                
                this.MakeGridHeader(x => x.LMESProductDataTemplate_dataStatus).SetTitle(@Localizer["Page.数据状态"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_enableStatus).SetTitle(@Localizer["Page.启用状态"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_equCode).SetTitle(@Localizer["Page.设备编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_equName).SetTitle(@Localizer["Page.设备名称"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_factoryCode).SetTitle(@Localizer["Page.工厂编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_operationCode).SetTitle(@Localizer["Page.工序编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_operationName).SetTitle(@Localizer["Page.工序名称"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramCode).SetTitle(@Localizer["Page.设备数采参数编号"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramCodeKey).SetTitle(@Localizer["Page.参数编码key"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramName).SetTitle(@Localizer["Page.设备数采参数名称"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramNameKey).SetTitle(@Localizer["Page.参数名称key"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramRange1).SetTitle(@Localizer["Page.上限值"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramRange2).SetTitle(@Localizer["Page.下限值"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramUnit).SetTitle(@Localizer["Page.参数单位"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_paramValueKey).SetTitle(@Localizer["Page.参数值的key"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_sort).SetTitle(@Localizer["Page.排序编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_actualsort).SetTitle(@Localizer["Page.实际编码顺序"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_standardValue).SetTitle(@Localizer["Page.标准值"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_stationCode).SetTitle(@Localizer["Page.工位编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_templateCode).SetTitle(@Localizer["Page.模板编码"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_uniqueCode).SetTitle(@Localizer["Page.设备唯一编号"].Value).SetSort(true),
                this.MakeGridHeader(x => x.LMESProductDataTemplate_IsValid).SetTitle(@Localizer["_Admin.IsValid"].Value).SetSort(true),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<LMESProductDataTemplate_View> GetSearchQuery()
        {
            var query = DC.Set<LMESProductDataTemplate>()
                
                .CheckContain(Searcher.DataStatus, x=>x.DataStatus)
                .CheckContain(Searcher.EnableStatus, x=>x.EnableStatus)
                .CheckContain(Searcher.EquCode, x=>x.EquCode)
                .CheckContain(Searcher.EquName, x=>x.EquName)
                .CheckContain(Searcher.FactoryCode, x=>x.FactoryCode)
                .CheckContain(Searcher.OperationCode, x=>x.OperationCode)
                .CheckContain(Searcher.OperationName, x=>x.OperationName)
                .CheckContain(Searcher.ParamCode, x=>x.ParamCode)
                .CheckContain(Searcher.ParamCodeKey, x=>x.ParamCodeKey)
                .CheckContain(Searcher.ParamName, x=>x.ParamName)
                .CheckContain(Searcher.ParamNameKey, x=>x.ParamNameKey)
                .CheckContain(Searcher.ParamRange1, x=>x.ParamRange1)
                .CheckContain(Searcher.ParamRange2, x=>x.ParamRange2)
                .CheckContain(Searcher.ParamUnit, x=>x.ParamUnit)
                .CheckContain(Searcher.ParamValueKey, x=>x.ParamValueKey)
                .CheckEqual(Searcher.Sort, x=>x.Sort)
                .CheckEqual(Searcher.Actualsort, x=>x.Actualsort)
                .CheckContain(Searcher.StandardValue, x=>x.StandardValue)
                .CheckContain(Searcher.StationCode, x=>x.StationCode)
                .CheckContain(Searcher.TemplateCode, x=>x.TemplateCode)
                .CheckContain(Searcher.UniqueCode, x=>x.UniqueCode)
                .Select(x => new LMESProductDataTemplate_View
                {
				    ID = x.ID,
                    
                    LMESProductDataTemplate_dataStatus = x.DataStatus,
                    LMESProductDataTemplate_enableStatus = x.EnableStatus,
                    LMESProductDataTemplate_equCode = x.EquCode,
                    LMESProductDataTemplate_equName = x.EquName,
                    LMESProductDataTemplate_factoryCode = x.FactoryCode,
                    LMESProductDataTemplate_operationCode = x.OperationCode,
                    LMESProductDataTemplate_operationName = x.OperationName,
                    LMESProductDataTemplate_paramCode = x.ParamCode,
                    LMESProductDataTemplate_paramCodeKey = x.ParamCodeKey,
                    LMESProductDataTemplate_paramName = x.ParamName,
                    LMESProductDataTemplate_paramNameKey = x.ParamNameKey,
                    LMESProductDataTemplate_paramRange1 = x.ParamRange1,
                    LMESProductDataTemplate_paramRange2 = x.ParamRange2,
                    LMESProductDataTemplate_paramUnit = x.ParamUnit,
                    LMESProductDataTemplate_paramValueKey = x.ParamValueKey,
                    LMESProductDataTemplate_sort = x.Sort,
                    LMESProductDataTemplate_actualsort = x.Actualsort,
                    LMESProductDataTemplate_standardValue = x.StandardValue,
                    LMESProductDataTemplate_stationCode = x.StationCode,
                    LMESProductDataTemplate_templateCode = x.TemplateCode,
                    LMESProductDataTemplate_uniqueCode = x.UniqueCode,
                    LMESProductDataTemplate_IsValid = x.IsValid,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class LMESProductDataTemplate_View: LMESProductDataTemplate
    {
        
        public string LMESProductDataTemplate_dataStatus { get; set; }
        public string LMESProductDataTemplate_enableStatus { get; set; }
        public string LMESProductDataTemplate_equCode { get; set; }
        public string LMESProductDataTemplate_equName { get; set; }
        public string LMESProductDataTemplate_factoryCode { get; set; }
        public string LMESProductDataTemplate_operationCode { get; set; }
        public string LMESProductDataTemplate_operationName { get; set; }
        public string LMESProductDataTemplate_paramCode { get; set; }
        public string LMESProductDataTemplate_paramCodeKey { get; set; }
        public string LMESProductDataTemplate_paramName { get; set; }
        public string LMESProductDataTemplate_paramNameKey { get; set; }
        public string LMESProductDataTemplate_paramRange1 { get; set; }
        public string LMESProductDataTemplate_paramRange2 { get; set; }
        public string LMESProductDataTemplate_paramUnit { get; set; }
        public string LMESProductDataTemplate_paramValueKey { get; set; }
        public int? LMESProductDataTemplate_sort { get; set; }
        public int? LMESProductDataTemplate_actualsort { get; set; }
        public string LMESProductDataTemplate_standardValue { get; set; }
        public string LMESProductDataTemplate_stationCode { get; set; }
        public string LMESProductDataTemplate_templateCode { get; set; }
        public string LMESProductDataTemplate_uniqueCode { get; set; }
        public bool LMESProductDataTemplate_IsValid { get; set; }

    }

}